﻿using System;
using System.Collections.Generic; 
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using System.Collections;

namespace LCWMS
{
    public partial class w_itf010 : DockContent
    {
        //返回的商品信息 格式sku
        public static string str_skucode;

        public w_itf010()
        {
            InitializeComponent();
            dgv_asn.AutoGenerateColumns = false;
        }

     
        private void w_itf010_Load(object sender, EventArgs e)
        {
            //获取按钮权限
            string str_right;
            str_right = main.g_class.comm_getright("w_itf010", main.g_right_dataset);
            //导出
            if (str_right.Substring(0, 2) == "0")
            {
                btn_outexcel.Visible = false;
            }
            else
            {
                btn_outexcel.Visible = true;
            }
            main.g_class.comm_changeControl(this, main.g_win_dataset);
           
        }

        //导出
        private void btn_outexcel_Click(object sender, EventArgs e)
        {
            if (dgv_export.Rows.Count > 0)
            {
                main.g_class.DataGridViewToExcel(dgv_export);
            }
        }

        private void btn_query_Click(object sender, EventArgs e)
        {
            DataSet ds_tmp = new DataSet();
            string str_temp="";
            dgv_export.Visible = true;
            dgv_asn.Visible = false;
            str_temp = "select  consignor,sku, pack_code,stock_qty_m  from " +
                 main.g_space + ".inv_sku  where inv_org = '"+main.g_org+"' order by consignor,sku";
            try
            {
                if (main.dbtype == "SQL")
                    ds_tmp = main.dbservice.Sql_exec_selectsql(str_temp);
                else
                    ds_tmp = main.dbservice.oracle_exec_selectsql(str_temp);

            }
            catch (System.Exception ee)
            {
                MessageBox.Show(main.g_class.comm_getchangestring("Fail to query", main.g_info_dataset) + "!" + ee.ToString());

                return;
            }
            if (ds_tmp.Tables[0].Rows.Count > 0)
                dgv_export.DataSource = ds_tmp.Tables[0];
            else
                dgv_export.DataSource = null;

        }
 
    }
}